package com.hello.tong.controller;

import com.hello.tong.entity.Order;
import com.hello.tong.service.IOrderService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tong-exists
 * @since 2022-12-31
 */
@RestController
public class OrderController {

    @Autowired
    private IOrderService orderService;

    @PostMapping("/create/{userId}/{commodityCode}/{orderCount}")
//    @GlobalTransactional
    public Order create(@PathVariable("userId") String userId,
                        @PathVariable("commodityCode") String commodityCode,
                        @PathVariable("orderCount")int orderCount) {
        return orderService.create(userId, commodityCode, orderCount);
    }

}
